package com.yc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.entity.Cartoon;
import com.yc.entity.Categorysecord;
import com.yc.mapper.CategorysecordMapper;
import com.yc.service.ICategorysecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 * InnoDB free: 4096 kB 服务实现类
 * </p>
 *
 * @author ly
 * @since 2022-05-25
 */
@Service
public class CategorysecordServiceImpl extends ServiceImpl<CategorysecordMapper, Categorysecord> implements ICategorysecordService {
    @Resource
    private CategorysecordMapper categorysecordMapper;

    @Override
    public List< Categorysecord > queryByCid(int cid) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("cid",cid);
        List<Categorysecord> list=categorysecordMapper.selectList(queryWrapper);
        return list;
        //SELECT csname from categorysecord where cid=1 and csid in (SELECT csid from cmap where ctid =4);
    }

    @Override
    public List< Categorysecord > queryByCsname(List< Cartoon > list,String edition,String classname) {
        String[] types=list.get(0).getCtype().split("/");
        List t=new ArrayList(types.length);
        Collections.addAll(t,types);
        t.add("全部");
        t.add(list.get(0).getShowYear());
        t.add(edition);
        t.add(classname);
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.in("csname",t);
        return categorysecordMapper.selectList(queryWrapper);
    }
}
